package com.rykj.energy.common.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@ApiModel("任务及摄像头运行关联表")
public class TaskCameraRelationDto {

    @ApiModelProperty(value = "算法任务关联ID" )
    private Integer id;

    @ApiModelProperty(value = "算法任务Id" )
    private Integer  taskId;

    @ApiModelProperty(value = "算法任务Code" )
    private String  taskCode;

    @ApiModelProperty(value = "摄像头Id" )
    private Integer  cameraId;

    @ApiModelProperty(value = "摄像头区域Id" )
    private Integer  orgId;

    @ApiModelProperty("球机预置位id")
    private Integer presetId;

    @ApiModelProperty("任务优先级")
    private Integer level;

    @ApiModelProperty(value = "任务类型，video:视频分析，capture:图片分析" )
    private String  taskType;

    @ApiModelProperty(value = "摄像头编号" )
    private String  cameraNo;

    @ApiModelProperty(value = "任务参数信息" )
    private String businessContent;

    @ApiModelProperty("任务状态,run,wait")
    private String status;

    @ApiModelProperty(value = "任务执行计划" )
    private String execPlan;

    @ApiModelProperty(value = "任务创建时间" )
    private Date createTime;

    @ApiModelProperty(value = "任务更新时间" )
    private Date updateTime;

    @ApiModelProperty(value = "任务所属用户" )
    private Integer createId;

    @ApiModelProperty(value = "摄像头检测的对象关联" )
    private List<CameraObjectDto> cameraObjectDtos;

    /**
     * 重写对比方法
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TaskCameraRelationDto relation = (TaskCameraRelationDto) o;
        if(presetId!=null&&presetId!=0){
            return  Objects.equals(taskCode, relation.taskCode)
                    &&(taskId+"").equals(relation.taskId+"")
                    &&(cameraId+"").equals(relation.cameraId+"")
                    &&(presetId+"").equals(relation.presetId+"");
        }else{
            return  Objects.equals(taskCode, relation.taskCode)
                    &&(taskId+"").equals(relation.taskId+"")
                    &&(cameraId+"").equals(relation.cameraId+"");
        }
    }

    @Override
    public int hashCode() {
        if(presetId!=null&&presetId!=0){
            return Objects.hash(taskCode,taskId,cameraId);
        }else{
            return Objects.hash(taskCode,taskId,cameraId,presetId);
        }
    }
}
